<include file="Index/header" />

<!-- 媒体对象 -->
<div class="container">
	<div class="media">
		<!-- 商品图片 -->
		<div class="media-left">
			<a href="#">
				<img class="media-object" src="__PUBLIC__/images/goods/{$goodsInfo[0][pic_url]}"
					alt="{$goodsInfo['goods_name']}" width="400px" height="400px">
			</a>
		</div>
		<!-- 商品详细信息 -->
		<div class="media-body">
			<h2 class="media-heading">{$goodsInfo['goods_name']}</h2>
			<p class="text-muted">
				<span>品牌编号：{$categoryInfo[0]['category_id']}</span>
				<span>品牌名称：{$categoryInfo[0]['category_name']}</span>
			</p>
			<p class="text-muted">商品编号：{$goodsInfo[0]['goods_id']}</p>
			<p class="text-muted">描述：{$goodsInfo[0]['goods_descript']}</p>
			<p class="text-muted">状态：
				<eq name="goodsInfo[0].goods_status" value="1">
					已上架
					<else />
					已下架,暂时无法购买
				</eq>
			</p>
			<eq name="goodsInfo[0].goods_status" value="1">
				<!--如果未上架，则无法购买 -->
				<p class="text-muted">商品价格：￥{$goodsInfo[0]['goods_price']}</p>
				<p class="text-muted">
					<span style="margin-right: 20px;">发货地址：{$goodsInfo[0]['goods_address']}</span>
					<neq name="goodsInfo[0].goods_qty" value="0">
						<span>库存:{$goodsInfo[0]['goods_qty']}</span>
						<else />
						<span>库存不足，暂时无货</span>
					</neq>
				</p>
				<neq name="goodsInfo[0].goods_qty" value="0">
					<!--库存不足，则无法购买 -->
					<p class="text-muted">会员编号：{$userInfo[0]['user_id']}</p>
					<p class="text-muted">收货人名称：{$userInfo[0]['u_name']}</p>
					<form action="?m=Home&c=order&a=centain" method="post" onsubmit="return checkForm()">
						<div class="form-group">
							<label for="u_phone">联系人电话</label>
							<input type="text" class="form-control" name="u_phone" id="u_phone"
								value="{$userInfo[0]['mobile_phone']}">
							<label for="u_address">收货地址</label>
							<input type="text" class="form-control" name="u_address" id="u_address"
								value="{$userInfo[0]['u_address']}">
						</div>
						<p class="text-muted">
							<label for="o_total">总金额：￥</label><span id='moneny'>{$goodsInfo[0]['goods_price']}</span>
							<label for="o_num">数量</label><input type="number" class="form-control" name="goods_count"
								id="g_num" value='1' min="1" max="{$goodsInfo[0]['goods_qty']}"
								onchange="countChange({$goodsInfo[0]['goods_price']})"
								οnkeypress='return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )'>
						</p>
						<br />
						<div>
							<button type="submit" class="btn btn-lg btn-primary" onclick="return orderCentain()">提
								交</button>
							<a href="?m=Home&c=goods&a=item&gi={$goodsInfo[0][goods_id]}" class="btn btn-lg btn-danger"
								onclick="return centainCancel()">取 消</a>
						</div>
						<!-- 会员编号、商品编号、分类编号 商品数量跟随表单一起传递过去-->
						<input type="hidden" name="user_id" value="{$userInfo[0]['user_id']}">
						<input type="hidden" name="goods_id" value="{$goodsInfo[0]['goods_id']}">
						<input type="hidden" name="category_id" value="{$categoryInfo[0]['category_id']}">
					</form>
					<else />
				</neq>
				<else />
			</eq>
		</div>
	</div>
	<br />
	<br />
	<br />
</div>

<script type="text/javascript">
	//进行初步非空检验
	function checkForm() {
		var patternt = /^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
		var uphone = document.getElementById('u_phone').value;
		var uaddress = document.getElementById('u_address').value;
		if (uphone == '') {
			alert('联系电话不能为空！');
			return false;
		}
		if (uaddress == '') {
			alert('收货地址不能为空！');
			return false;
		}
		if (patternt.test(uphone))  //手机号有效检测
		{
			return true;
		}
		window.confirm("手机号格式有误");
		return false;
	}
	//取消订单确认
	function centainCancel() {
		if (window.confirm("确认取消该订单吗?")) {
			return true;
		}
		return false;
	}
	//订单确认
	function orderCentain() {
		if (window.confirm("确认提交该订单吗?")) {
			return true;
		}
		return false;
	}
	//数量值发生变化时
	function countChange(price) {
		var count = document.getElementById('g_num');  //获取数量input框
		var totalMoneny = document.getElementById('moneny');   //获取总金额对象
		totalMoneny.innerHTML = (count.value * price).toFixed(2);
	}
</script>

<include file="Index/footer" />